import unittest
from api.ihrm_login_api import IhrmLoginApi
from api.ihrm_emp_curd_api import IhrmEmpCURD
from common.assrt_login import assert_login


class TestIhrmAdd(unittest.TestCase):
    headers = {}

    @classmethod
    def setUpClass(cls):
        login_token = "Bearer " + IhrmLoginApi.ihrm_login_api({
            "mobile": "13800000002", "password": "929itheima.CN032@.20250227"
        }).json().get("data")
        cls.headers = {
            "Content-Type": "application/json",
            "Authorization": login_token
        }

    def test_add_ok(self):
        # 准备数据
        add_json_data = {
            "username": "小猪佩奇",
            "mobile": "15165964379",
            "workNumber": "9527",
        }
        # 调用add接口方法
        resp = IhrmEmpCURD.add_emp(self.headers, add_json_data)
        print(resp.json())
        # 断言
        assert_login(self, resp, 200, True, 10000, "操作成功")

    def test_add_no(self):
        # 准备数据
        add_json_data = {
            "username": "小猪佩奇",
            "mobile": "15165961379",
            "workNumber": "9527",
        }
        # 调用add接口方法
        resp = IhrmEmpCURD.add_emp(self.headers, add_json_data)
        print(resp.json())
        # 断言
        assert_login(self, resp, 200, False, 99999, "当前手机号码已存在")



